DateInfo: Fix timeToStringWithFormat buffer length
authorErich E. Hoover <erich.e.hoover@gmail.com>
Thu, 2 Jul 2026 16:52:33 +0000 (16:52 +0000)
committerJohn Scott <jscott@posteo.net>
Thu, 2 Jul 2026 16:52:33 +0000 (16:52 +0000)
Origin: upstream, https://gitlab.freedesktop.org/poppler/poppler/-/merge_requests/1824.patch
Applied-Upstream: 25.06.0, https://gitlab.freedesktop.org/poppler/poppler/-/commit/55169105e121d5fbb7c50e2c744d750de5d0a7de
Bug: https://gitlab.freedesktop.org/poppler/poppler/-/work_items/1596
Bug-Debian: https://bugs.debian.org/1127146
Reviewed-By: John Scott <jscott@posteo.net>
Last-Update: 2026-07-01

strftime places a NULL-terminated string in the buffer, so the std::string
buffer needs to be resized to not include the terminator character
(or anything after it).

Without this fix, modification dates in altered PDF documents (such as when
adding a digital signature) are not truncated properly, instead padding
the date with a null byte and extra spaces until the end of the buffer is
reached. This bad syntax compromises the ability to verify the signature
with other applications, but the Poppler signatory has no indication of this.

Gbp-Pq: Name malformed-moddate.patch

poppler/DateInfo.cc

index 3c893e0ad5fe03a8a36af74c364dab0497d6e4e0..8f342368fff2628a1522f5e28d3e3ed5da26b2df 100644 (file)
@@ -122,6 +122,7 @@ std::string timeToStringWithFormat(const time_t *timeA, const char *format)
     while (strftime(&buf[0], buf.size(), fmt.c_str(), &localtime_tm) == 0) {
         buf.resize(bufLen *= 2);
     }
+    buf.resize(buf.find('\0'));
     return buf;
 }